<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  function isValidDate(dateString) {
    // 使用正则表达式进行验证
    const regex = /^(\d{4})-(\d{2})-(\d{2})$/;
    if (!regex.test(dateString)) { // 检查格式是否正确
      return false;
    }

    // 解析年、月、日
    const [, year, month, day] = dateString.match(regex);

    // 检查月份和日期是否正常
    const date = new Date(year, parseInt(month) - 1, day);
    return (
            date.getFullYear() == year &&
            date.getMonth() + 1 == month &&
            date.getDate() == day
    );
  }

  // 测试
  console.log(isValidDate("2008-13-32")); // false
  console.log(isValidDate("2023-10-17")); // true

</script>
</body>
</html>
